$(function () {
    $("#addStrategy").click(function () {
        $(".add_div").fadeToggle();
    });
    $("#addStrategyN").click(function () {
        $(".add_div").fadeToggle();
    });

    //查询策略列表数据
    function getTable() {
        var _timestamp = new Date().getTime();
        var _secret = hex_md5(ip + '/Back/Strategy/MainList?timestamp=' + _timestamp + salt);
        $.ajax({
            type: "POST",
            url: ip + '/Back/Strategy/MainList?timestamp=' + _timestamp + '&secret=' + _secret + '&token=' + _token,
            dataType: 'json',
            headers: {
                "Content-Type": "application/json",
                "Accept": "application/json;charset=utf-8",
            },
            xhrFields: {withCredentials: true},
            success: function (data) {
                console.log(data);
                var result = JSON.stringify(data);
                if (data.code == 1) {
                    $("#strategyTable tbody tr").remove();
                    var count = data.data.length;
                    for (var i = 0; i < count; i++) {
                        var id = data.data[i].id || '';
                        var amountSubscribe = data.data[i].amountSubscribe || '';
                        var gmtCreate = data.data[i].gmtCreate || '';
                        gmtCreate == "" ? gmtCreate = "" : gmtCreate = getMyDate(gmtCreate);
                        var gmtFirstTrade = data.data[i].gmtFirstTrade || '';
                        var gmtModified = data.data[i].gmtModified || '';
                        var introduce = data.data[i].introduce || '';
                        var introduce_;
                        introduce.length > 10 ? introduce_ = introduce.substring(0, 10) + " ··· " : introduce_ = introduce;
                        var inventorId = data.data[i].inventorId || '';
                        var marketId = data.data[i].marketId || '';
                        var marketName = data.data[i].marketName || '';
                        var strategyAvailableCapital = data.data[i].strategyAvailableCapital || '';
                        var strategyCapital = data.data[i].strategyCapital || '';
                        var strategyFinanceCapital = data.data[i].strategyFinanceCapital || '';
                        var strategyId = data.data[i].strategyId || '';
                        var strategyLevel = data.data[i].strategyLevel || '';
                        var strategyName = data.data[i].strategyName || '';
                        var strategyNetWorth = data.data[i].strategyNetWorth || '';
                        var strategyProfitRate = data.data[i].strategyProfitRate || '';
                        var _strategyState = data.data[i].strategyState || '';
                        var strategyType = data.data[i].strategyType || '';
                        strategyType == 1 ? strategyType = "公开" : strategyType = "私有";

                        var tr = "<tr Money=" + strategyAvailableCapital + " name=" + strategyName + " marketId=" + marketId + " _id=" + id + " strategyId=" + strategyId + " strategyState=" + _strategyState + "><td>" + strategyId + "</td><td>" + strategyName + "</td><td><img src=img/stop_" + _strategyState + ".png alt=''width='20' height='20'></td><td>" + marketName + "</td><td>" + strategyAvailableCapital + "</td><td>" + strategyType + "</td><td>" + strategyLevel + "</td><td>" + amountSubscribe + "</td><td>" + gmtCreate + "</td><td><abbr title=" + introduce + ">" + introduce_ + "</abbr></td><td><button class='holdTable' id=holdTable_" + i + "><i class='i-color2 icon-archive'>&nbsp;</i>持仓管理</button></td><td><button class='adjustment' id=adjustment_" + i + "><i class='i-color1 icon-book'>&nbsp;</i>调仓记录</button></td></tr>";
                        $("#strategyTable tbody").append(tr);
                        holdAndAdjustment(i);
                    }
                }
            },
            error: function () {
                alert('请求失败');
            }
        });
    }

    getTable();
//创建策略
    $("#addStrategyY").click(function () {
        var _timestamp = new Date().getTime();
        var _secret = hex_md5(ip + '/Back/Strategy/AllTrade?timestamp=' + _timestamp + salt);
        var _introduce = $("#introduce").val();
        var _marketId = $("#marketId option:selected").val();
        var _strategyCapital = $("#strategyCapital").val();
        var _strategyLevel = $("#strategyLevel").val();
        var _strategyName = $("#strategyName").val();
        var _strategyType = $("#strategyType option:selected").val();
        _strategyName != '' ? $("#strategyNameSpan").fadeOut() : $("#strategyNameSpan").fadeIn();
        _introduce != '' ? $("#introduceSpan").fadeOut() : $("#introduceSpan").fadeIn()
        _strategyCapital != '' ? $("#strategyCapitalSpan").fadeOut() : $("#strategyCapitalSpan").fadeIn()
        _strategyLevel != '' ? $("#strategyLevelSpan").fadeOut() : $("#strategyLevelSpan").fadeIn()

        if (_strategyName != '' && _introduce != '' && _strategyCapital != '' && _strategyLevel != '') {
            $.ajax({
                type: "POST",
                url: ip + '/Back/Strategy/Create?timestamp=' + _timestamp + '&secret=' + _secret + '&token=' + _token,
                dataType: 'json',
                headers: {
                    "Content-Type": "application/json",
                    "Accept": "application/json;charset=utf-8",
                },
                data: JSON.stringify({
                    "introduce": _introduce,
                    "marketId": _marketId,
                    "strategyCapital": parseInt(_strategyCapital),
                    "strategyLevel": parseInt(_strategyLevel),
                    "strategyName": _strategyName,
                    "strategyType": _strategyType
                }),
                success: function (data) {
                    // var result = JSON.stringify(data);
                    if (data.code == 1) {
                        getTable();
                        console.log(data.message);
                        $(".add_div").fadeOut();
                        $(".add_div input ").val("");
                        $(".add_div textarea ").val("");
                    }
                },
                error: function () {
                    alert('创建策略失败');
                },
            })
        }

    })

    // 持仓管理和调仓管理
    function holdAndAdjustment(i) {
        // 持仓按钮事件
        $("#holdTable_" + i).click(function () {
            var strategyId = $(this).parent().parent().attr("strategyId");
            var strategyState = $(this).parent().parent().attr("strategyState");
            var marketId = $(this).parent().parent().attr("strategyState");
            var name = $(this).parent().parent().attr("name");
            var Money = $(this).parent().parent().attr("Money");
            getHoldTable(strategyId, strategyState, marketId, name, Money)
        });

        // 调仓列表
        $("#adjustment_" + i).click(function () {
            var _strategyId = $(this).parent().parent().attr("strategyId");
            getTransferTable(_strategyId);
        })
    };

    $("#noneBuy").click(function () {
        alert("停用策略无法购买")
    })
    // 查询持仓表方法
    function getHoldTable(_strategyId, _strategyState, _marketId, _name, _Money) {
        $(".hold_position").attr({
            'strategyId': _strategyId,
            'strategyState': _strategyState,
            'marketId': _marketId,
            "_name": _name,
            "_Money": _Money
        });
        var _timestamp = new Date().getTime();
        var _secret = hex_md5(ip + '/Back/Strategy/AllPosition?timestamp=' + _timestamp + salt);
        $.ajax({
            type: "POST",
            url: ip + '/Back/Strategy/AllPosition?timestamp=' + _timestamp + '&secret=' + _secret + '&token=' + _token,
            dataType: 'json',
            headers: {
                "Content-Type": "application/json",
                "Accept": "application/json;charset=utf-8",
            },
            data: JSON.stringify({
                "strategyId": _strategyId
            }),
            success: function (data) {
                // var result = JSON.stringify(data);
                console.log(data)
                if (data.code == 1 && _strategyState == 1) {
                    $("#buyNewStock").css({"display": "block"});
                    $("#noneBuy").css({"display": "none"});
                    $("#holdTable tbody tr").remove();
                    var count = data.data.length;
                    for (var i = 0; i < count; i++) {
                        var _gmtModified = data.data[i].gmtModified || '';
                        var _marketName = data.data[i].marketName || '';
                        var _nowPrice = data.data[i].nowPrice || '';
                        var _positionPrice = data.data[i].positionPrice || '';
                        var _positionVolume = data.data[i].positionVolume || '';
                        var _profitRate = data.data[i].profitRate || '';
                        var _stockId = data.data[i].stockId || '';
                        var _stockName = data.data[i].stockName || '';
                        var _tradeDirectionName = data.data[i].tradeDirectionName || '';
                        var _tradeType = data.data[i].tradeType || '';
                        var _profitRate = (data.data[i].profitRate != '' && data.data[i].profitRate != '0' && data.data[i].profitRate != undefined) ? (data.data[i].profitRate * 100).toFixed(2) + '%' : "0%";
                        var _tradeDirectionName = data.data[i].tradeDirectionName || '';
                        _tradeDirectionName == '多' ? _tradeDirectionName = '多头' : _tradeDirectionName = '空头';
                        var _positionProfitRate = data.data[i].positionProfitRate || '';
                        var _gmtCreate = data.data[i].gmtCreate || '';
                        _gmtCreate != '' ? _gmtCreate = getMyDate(_gmtCreate) : _gmtCreate = '';
                        var tr = "<tr _stockId=" + _stockId + "><td>" + _stockId + "</td><td>" + _stockName + "</td><td>" + _gmtCreate + "</td><td>" + _positionPrice + "</td><td>" + _positionVolume + "</td><td>" + _tradeDirectionName + "</td><td>" + _profitRate + "</td><td><button class='buyView btn btn-color-blue'><i class='icon-arrow-down'>&nbsp;</i>买入</button><button class='sellView btn btn-color-red' ><i class='icon-arrow-up'>&nbsp;</i>卖出</button></td></tr>";
                        $("#holdTable tbody").append(tr);
                    }
                    ;
                    buyAndSell();
                    $(".hold_position").fadeIn();
                }
                if (data.code == 1 && _strategyState != 1) {
                    $("#buyNewStock").css({"display": "none"});
                    $("#noneBuy").css({"display": "block"});
                    $("#holdTable tbody tr").remove();
                    var count = data.data.length;
                    for (var i = 0; i < count; i++) {
                        var _gmtModified = data.data[i].gmtModified || '';
                        var _marketName = data.data[i].marketName || '';
                        var _nowPrice = data.data[i].nowPrice || '';
                        var _positionPrice = data.data[i].positionPrice || '';
                        var _positionVolume = data.data[i].positionVolume || '';
                        var _stockId = data.data[i].stockId || '';
                        var _stockName = data.data[i].stockName || '';
                        var _tradeDirectionName = data.data[i].tradeDirectionName || '';
                        var _positionTradeDirection = data.data[i].positionTradeDirection || '';
                        _positionTradeDirection == '1' ? _positionTradeDirection = '多头' : _positionTradeDirection = '空头';
                        var _positionProfitRate = data.data[i].positionProfitRate || '';
                        var _tradeType = data.data[i].tradeType || '';
                        var _gmtCreate = data.data[i].gmtCreate || '';
                        _gmtCreate != '' ? _gmtCreate = getMyDate(_gmtCreate) : _gmtCreate = '';
                        var _profitRate = (data.data[i].profitRate != '' && data.data[i].profitRate != '0' && data.data[i].profitRate != undefined) ? (data.data[i].profitRate * 100).toFixed(2) + '%' : "0%";
                        var tr = "<tr _stockId=" + _stockId + "><td>" + _stockId + "</td><td>" + _stockName + "</td><td>" + _gmtCreate + "</td><td>" + _positionPrice + "</td><td>" + _positionVolume + "</td><td>" + _tradeDirectionName + "</td><td>" + _profitRate + "</td><td>停用策略无法买卖</td></tr>";
                        $("#holdTable tbody").append(tr);
                    };

                    $(".hold_position").fadeIn();
                }

                if (data.code != 1) {
                    alert(data.message)
                }
            },
            error: function () {
                alert('请求持仓列表失败');
            }
        })
    };

    // 买入卖出弹出对话框
    function buyAndSell() {
        $(".buyView").click(function () {
            $("#buyView input").val("");
            var _stockId = $(this).parent().parent().attr("_stockId");
            var _stockName = $(this).parent().parent().find("td").eq(1).text();
            var _buyPrice = $(this).parent().parent().find("td").eq(3).text();
            $("#buyStockId").val(_stockId);
            $("#buyStockName").val(_stockName);
            $("#buyPrice").val(_buyPrice);
            $("#canBuyMoney").html("可用:" + $(".hold_position").attr("_money"));
            $("#canBuyMoney").attr({"Money": $(".hold_position").attr("_money")});
            var timestamp = new Date().getTime();
            var timeNow = new Date(timestamp).Format("yyyy-MM-ddThh:mm:ss");
            $("#buyTime").val(timeNow);
            $("._h2strategyName").html($(".hold_position").attr("_name"));
            $("#buy_range_slider").val(0);
            $("#buy_range_slider").css({"background-size": '0% 100%'});
            $("#buyStockId").attr({"readonly": "readonly"});
            $(".business").fadeOut();
            $("#buyView").fadeIn()
        });
        $(".sellView").click(function () {
            $("#sellView input").val("");
            var _stockId = $(this).parent().parent().attr("_stockId");
            var _stockName = $(this).parent().parent().find("td").eq(1).text();
            var _buyPrice = $(this).parent().parent().find("td").eq(3).text();
            var _myHoldStock = $(this).parent().parent().find("td").eq(4).text();
            var _myHoldMethod = $(this).parent().parent().find("td").eq(5).text();
            var myHoldStock = $(this).parent().parent().find("td").eq(4).text();
            var timestamp = new Date().getTime();
            var timeNow = new Date(timestamp).Format("yyyy-MM-ddThh:mm:ss");
            $("#sellTime").val(timeNow);
            $("._h2strategyName").html($(".hold_position").attr("_name"))
            $("#sellStockId").val(_stockId);
            $("#sellstockName").val(_stockName);
            $("#myHoldStock").val(_myHoldStock);
            $("#holdPrice").val(_buyPrice);
            $("#sellPrice").val(_buyPrice);
            $("#myHoldMethod").val(_myHoldMethod);
            $("#sell_range_slider").val(0);
            $("#sell_range_slider").css({"background-size": '0% 100%'});
            $(".business").fadeOut()
            $("#sellView").fadeIn()

        })
    }

    //买入卖出联动
    $("#buyPrice,#buyCount").blur(function () {
        var _buyPrice = $("#buyPrice").val()
        var _buyCount = $("#buyCount").val();
        _buyPrice != '' && _buyCount != '' ? $("#buySum").val(_buyPrice * _buyCount) : console.log("请填写买入量");
    });

    $("#sellPrice,#sellCount").blur(function () {
        var _sellPrice = $("#sellPrice").val();
        var _sellCount = $("#sellCount").val();
        var _myHoldStock = $("#myHoldStock").val();
        _sellPrice != '' && _sellCount != '' ? $("#sellSum").val(_sellCount * _sellPrice) : console.log("请填写买入量");
        $("#sellProportion").val(Math.ceil(_sellCount / _myHoldStock * 100) + '%');
        $("#sell_range_slider").val(parseFloat($("#sellProportion").val()));
        $("#sell_range_slider").css({"background-size": $("#sellProportion").val() + '100%'});
    });

    //买入比例条
    $("#buy_range_slider").bind('input porpertychange', function () {
        $("#buyProportion").val($("#buy_range_slider").val() + '%')
        $("#buyCount").val(Math.floor($("#buy_range_slider").val() / 100 * $("#canBuyMoney").attr('Money') / $("#buyPrice").val()));
        var sum = $("#buyPrice").val() * $("#buyCount").val();
        $("#buySum").val(sum);
    });
    //卖出比例条
    $("#sell_range_slider").bind('input porpertychange', function () {
        $("#sellProportion").val($("#sell_range_slider").val() + '%');
        var sellCount = parseInt(parseFloat($("#sell_range_slider").val()) / 100 * $("#myHoldStock").val())
        $("#sellCount").val(sellCount);
        $("#sellSum").val(sellCount * $("#sellPrice").val());
//逻辑部分
    });
    // 手动输入卖出比例
    $("#sellProportion").blur(function () {
        $("#sellProportion").val(parseFloat($("#sellProportion").val()) + '%');
        var sellCount = parseInt(parseFloat($("#sellProportion").val()) / 100 * $("#myHoldStock").val());
        $("#sell_range_slider").val(parseFloat($("#sellProportion").val()));
        $("#sell_range_slider").css({"background-size": $("#sellProportion").val() + '100%'});
        $("#sellCount").val(sellCount);
        $("#sellSum").val(sellCount * $("#sellPrice").val());
    });
    //手动买入
    $("#buyProportion").blur(function () {
        $("#buyProportion").val(parseFloat($("#buyProportion").val()) + '%');
        $("#buy_range_slider").val(parseFloat($("#buyProportion").val()));
        $("#buy_range_slider").css({"background-size": $("#buyProportion").val() + '100%'});
        var buyCount = Math.floor($("#buy_range_slider").val() / 100 * $("#canBuyMoney").attr('Money') / $("#buyPrice").val());
        $("#buyCount").val(buyCount);
        $("#buySum").val($("#buyCount").val() * $("#buyPrice").val());
    });
    //关闭买卖框

    $("#buyViewClose").click(function () {
        $(".business").fadeOut()

    });
    $("#SellViewClose").click(function () {
        $(".business").fadeOut()
    });

    //关闭调仓表
    $(".closeAdjustTable").click(function () {
        $("#adjustTable").fadeOut()
    });

    //查询调仓的方法

    function getTransferTable(_strategyId) {
        var _timestamp = new Date().getTime();
        var _secret = hex_md5(ip + '/Back/Strategy/AllTrade?timestamp=' + _timestamp + salt);
        $.ajax({
            type: "POST",
            url: ip + '/Back/Strategy/AllTrade?timestamp=' + _timestamp + '&secret=' + _secret + '&token=' + _token,
            dataType: 'json',
            headers: {
                "Content-Type": "application/json",
                "Accept": "application/json;charset=utf-8",
            },
            data: JSON.stringify({
                "page": 1,
                "sortType": 1,
                "strategyId": _strategyId
            }),
            success: function (data) {
                // var result = JSON.stringify(data);
                console.log(data)
                if (data.code == 1) {
                    $("#adjustTable tbody tr").remove();
                    var count = data.data.length;
                    for (var i = 0; i < count; i++) {
                        var _gmtTrade = data.data[i].gmtTrade || '';
                        _gmtTrade != '' ? _gmtTrade = getMyDate(_gmtTrade) : _gmtTrade = '';
                        var _id = data.data[i].marketName || '';
                        var _isRead = data.data[i].nowPrice || '';
                        var _marketId = data.data[i].positionPrice || '';
                        var _marketName = data.data[i].positionVolume || '';
                        var _profitRate = data.data[i].profitRate || '';
                        var _stockId = data.data[i].stockId || '';
                        var _stockName = data.data[i].stockName || '';
                        var _tradeDirection = data.data[i].tradeDirection || '';
                        var businessFx = '';
                        var businessFs = '';
                        if (_tradeDirection == 1) {
                            businessFs = '多头';
                            businessFx = '买入'
                        }
                        if (_tradeDirection == 2) {
                            businessFs = '空头';
                            businessFx = '买入'
                        }
                        if (_tradeDirection == 3) {
                            businessFs = '多头';
                            businessFx = '卖出'
                        }
                        if (_tradeDirection == 4) {
                            businessFs = '空头';
                            businessFx = '卖出'
                        }
                        var _tradePrice = data.data[i].tradePrice || '';
                        var _tradeVolume = data.data[i].tradeVolume==0||data.data[i].tradeVolume==undefined?0:data.data[i].tradeVolume;
                        var _profitRate = data.data[i].profitRate || '';
                        var _trageProfitRate = (data.data[i].trageProfitRate != '' && data.data[i].trageProfitRate != '0' && data.data[i].trageProfitRate != undefined) ? (data.data[i].trageProfitRate * 100).toFixed(2) + '%' : "0%";
                        var tr = "<tr _stockId=" + _stockId + "><td>" + _stockId + "</td><td>" + _stockName + "</td><td>" + _gmtTrade + "</td><td>" + businessFx + "</td><td>" + _tradePrice + "</td><td>" + _tradeVolume + "</td><td>" + businessFs + "</td><td>" + _trageProfitRate + "</td></tr>";
                        $("#adjustTable tbody").append(tr);
                    }
                    $("#adjustTable").fadeIn()
                }
                else {
                    alert(data.message)
                }
            },
            error: function () {
                alert('请求持仓列表失败');
            }
        })
    };

    //关闭hold_position
    $(".closeHold").click(function () {
        $(".hold_position").fadeOut();
    })
    //买入新股票
    $("#buyNewStock").click(function () {
        $("#buyView input").val("");
        var timestamp = new Date().getTime();
        var timeNow = new Date(timestamp).Format("yyyy-MM-ddThh:mm:ss");
        $("#buyTime").val(timeNow);
        $("#canBuyMoney").html("可用:" + $(".hold_position").attr("_money"));
        $("#canBuyMoney").attr({"Money": $(".hold_position").attr("_money")});
        $("#buy_range_slider").val(0);
        $("#buy_range_slider").css({"background-size": '0% 100%'});
        $("#canBuyMoney").html($(".hold_position").attr("_money"));
        $("._h2strategyName").html($(".hold_position").attr("_name"));
        $("#buyStockId").removeAttr("readonly");
        $(".business").fadeOut();
        $("#buyView").fadeIn();
    });
    //发送买入请求
    $("#buyNow").click(function () {
        var moneyNow = ($(".hold_position").attr("_money") - $("#buySum").val()).toFixed(2);
        var _timestamp = new Date().getTime();
        var _secret = hex_md5(ip + '/Back/Strategy/Buy?timestamp=' + _timestamp + salt);
        $.ajax({
            type: "POST",
            url: ip + '/Back/Strategy/Buy?timestamp=' + _timestamp + '&secret=' + _secret + '&token=' + _token,
            dataType: 'json',
            headers: {
                "Content-Type": "application/json",
                "Accept": "application/json;charset=utf-8",
            },
            data: JSON.stringify({
                "marketId": $(".hold_position").attr('marketid'),
                "stockId": $("#buyStockId").val(),
                "stockName": $("#buyStockName").val(),
                "strategyId": parseInt($(".hold_position").attr("strategyid")),
                "tradeDate": $("#buyTime").val().split("T").join(" "),
                "tradeDirection": $("#buyTradeDirection option:selected").val(),
                "tradePrice": parseFloat($("#buyPrice").val()),
                "tradeVolume": parseInt($("#buyCount").val()),
            }),
            success: function (data) {
                // var result = JSON.stringify(data);
                console.log(data)
                if (data.code == 1) {
                    $(".business").fadeOut();
                    setTimeout(function () {
                        $(".business input").val('')
                    }, 200);
                    getTable();
                    getHoldTable($(".hold_position").attr('strategyid'), $(".hold_position").attr('strategystate'), $(".hold_position").attr('marketid'));
                    $(".hold_position").attr({"_money": moneyNow});
                }
                else {
                    alert(data.message)
                }
            },
            error: function () {
                alert('请求持仓列表失败');
            }
        })
    })
    //发送卖出请求
    $("#sellNow").click(function () {
        var tradeDirection = $("#myHoldMethod").val() == '空头' ? 4 : 3;
        var moneyNow = (parseFloat($("#sellSum").val()) + parseFloat($(".hold_position").attr("_money"))).toFixed(2);
        var _timestamp = new Date().getTime();
        var _secret = hex_md5(ip + '/Back/Strategy/Sell?timestamp=' + _timestamp + salt);
        $.ajax({
            type: "POST",
            url: ip + '/Back/Strategy/Sell?timestamp=' + _timestamp + '&secret=' + _secret + '&token=' + _token,
            dataType: 'json',
            headers: {
                "Content-Type": "application/json",
                "Accept": "application/json;charset=utf-8",
            },
            data: JSON.stringify({
                "marketId": $(".hold_position").attr('marketId'),
                "stockId": $("#sellStockId").val(),
                "stockName": $("#sellstockName").val(),
                "strategyId": parseInt($(".hold_position").attr("strategyid")),
                "tradeDate": $("#sellTime").val().split("T").join(" "),
                "tradeDirection": tradeDirection,
                "tradePrice": parseFloat($("#sellPrice").val()),
                "tradeVolume": parseInt($("#sellCount").val()),
            }),
            success: function (data) {
                // var result = JSON.stringify(data);
                console.log(data)
                if (data.code == 1) {
                    $(".business").fadeOut();
                    setTimeout(function () {
                        $(".business input").val('')
                    }, 200);
                    getTable();
                    getHoldTable($(".hold_position").attr('strategyid'), $(".hold_position").attr('strategystate'), $(".hold_position").attr('marketid'));
                    $(".hold_position").attr({"_money": moneyNow});
                }
                else {
                    alert(data.message)
                }
            },
            error: function () {
                alert('请求持仓列表失败');
            }
        })
    });
    //表头固定
    var tableCont = document.querySelector('#strategyTableDiv');
    var holdTableDiv = document.querySelector('#holdTableDiv');
    var tcTableDiv = document.querySelector('#tcTableDiv');

    tableCont.addEventListener('scroll', scrollHandle);
    holdTableDiv.addEventListener('scroll', scrollHandle);
    tcTableDiv.addEventListener('scroll', scrollHandle);
    tcTableDiv.addEventListener('scroll', scrollHandle);
})